
#ifndef __B_HAL_PWM_H
#define __B_HAL_PWM_H

#ifdef __cplusplus
extern "C" {
#endif

/*Includes ----------------------------------------------*/
#include "b_hal.h"

/**
 * \addtogroup B_HAL
 * \{
 */

/**
 * \addtogroup PWM
 * \{
 */

/**
 * \defgroup PWM_Exported_Types
 * \{
 */

typedef enum
{
    PWM_CHANNEL_1 = 0,
    PWM_CHANNEL_2,
    PWM_CHANNEL_3,
    PWM_CHANNEL_4,
} bPwmChannel_t;

typedef enum
{
    PWM_MODE_NORMAL = 0,    /* Normal PWM mode */
    PWM_MODE_CENTER_ALIGNED, /* Center-aligned PWM mode */
} bPwmMode_t;

typedef enum
{
    PWM_POLARITY_HIGH = 0,  /* High polarity (active high) */
    PWM_POLARITY_LOW,       /* Low polarity (active low) */
} bPwmPolarity_t;

typedef struct
{
    bPwmChannel_t channel;      /* PWM channel */
    bPwmMode_t mode;           /* PWM mode */
    bPwmPolarity_t polarity;   /* PWM polarity */
    uint32_t frequency;        /* PWM frequency in Hz */
    uint8_t duty;             /* PWM duty cycle (0-100) */
} bPwmConfig_t;

/**
 * \}
 */

/**
 * \defgroup PWM_Exported_Functions
 * \{
 */

int bHalPwmInit(bPwmConfig_t *config);
int bHalPwmDeInit(bPwmChannel_t channel);
int bHalPwmStart(bPwmChannel_t channel);
int bHalPwmStop(bPwmChannel_t channel);
int bHalPwmSetDuty(bPwmChannel_t channel, uint8_t duty);
int bHalPwmSetFrequency(bPwmChannel_t channel, uint32_t frequency);

/**
 * \}
 */

/**
 * \}
 */

/**
 * \}
 */

#ifdef __cplusplus
}
#endif

#endif /* __B_HAL_PWM_H */

/************************ Copyright (c) 2024 Bean *****END OF FILE****/ 